<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title><?=getValInArr(getSess(SESS_DIC),array('webInfo','webtitle'))?></title>
	<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport"/>
	<meta content="yes" name="apple-mobile-web-app-capable"/>
	<meta content="black" name="apple-mobile-web-app-status-bar-style"/>
	<meta content="telephone=no" name="format-detection"/>
	<script type="text/javascript" src="<?php echo base_url().'public/home/js/' ?>jquery.js"></script>
	<?php include_once "public/home/html/bootstrap.php"  ?>
	<link rel="stylesheet" href="<?php echo base_url().'public/h_ui/lib/Hui-iconfont/1.0.8/' ?>iconfont.css">
	<link rel="stylesheet" href="<?php echo base_url().'public/home/css/' ?>mui.min.css">
	<script type="text/javascript" src="<?php echo base_url().'public/home/js/' ?>function.js"></script>
	<?php include_once "public/home/html/search-select.php";
	include_once "public/home/html/alert.php";
		include_once 'public/home/html/mobile_select.php';  ?>
<!-- 日期选择控件 -->
<script src='<?php echo base_url().'public/home/mobile_date/' ?>jdate.min.js'></script>
<!-- input搜索框 -->
<script src='<?php echo base_url().'public/home/mobile_input_search/' ?>ansel_select.js'></script>
</head>
<body>
	<style>
	body{
		padding: 3%;
		background-color: #ffffff;
		/*overflow:visible*/
	}
	.float_left{
		float: left;
	}
	.clear{
		clear: both;
	}
	select{
		width: 60%!important;
	}
	.screen{
		margin-top: 15%;
		padding-left: 10%;
		padding-right: 10%;
		width: 100%;	
	}
	#start_time +.searchable-select .searchable-select-dropdown{
		z-index: 10;
	}
	#teacher +.searchable-select  .searchable-select-dropdown{
		z-index: 9;
	}
	.searchable-select{
		min-width: 150px;
	}
	#teacher_name{
		position:absolute;
	}
	.searchable-select-holder {
    min-height: 40px;
    }
    .searchable-select-dropdown{
    	z-index: 10
    }
    .ansel_input {
    width:40%;
    border-radius:4px;
    margin-left: 2%
}
.ansel_input .ansel_inputval {
    line-height: 21px;
    width: 100%;
    height: 35px;
    margin-bottom: 15px;
    padding: 10px 15px;
    -webkit-user-select: text;
    border: 1px solid rgba(0, 0, 0, .2);
    border-radius: 3px;
    outline: 0;
    background-color: #fff;
    -webkit-appearance: none;
    font-size: 15px;

}
.mui-bar .mui-title{
	    overflow: visible;
}
#search{
	margin-left:5%;
}
li div{
	font-size: 14px
}

</style>
<input type="hidden" name='url' value="<?php echo base_url()?>">
<div class="search-head header mui-bar mui-bar-nav row" style="background-color: #f7f9fa; border:none;">
	<div class="col-xs-1" style="margin-top: 3%">
		<a class=" Hui-iconfont Hui-iconfont-slider-left" href="javascript:void(0)" onclick="history.back();" style="color: #C9C9C9"></a>
	</div>
	<div class="col-xs-11">
		<h1 class="mui-title" style="color:#333;margin-left: -5%">课程列表</h1>
	</div>
	</div>
 <div style="margin-top: 15%;margin-left:5%;width: 100%">
 	<input type="hidden" value="<?=$max_week?>" id="max_week" >
 	<select name="" class="teacher_name" class=" " isval='falses' onFocus="this.blur();" unselectable="on"> 	 
 	</select>
 	<input type="text" class='input float_left' id='term' placeholder="学期" readonly  onFocus="this.blur();"  style="width:40%;margin-left:6%;font-size: 15px;
   height: 35px;margin-right: 3%;" />
 	<button class="btn btn-primary hide" id='search'>搜索</button>
 	<br>
	<input type="text" class='input float_left'id='select_date' placeholder="教学周" readonly style="width:40%;margin-left:3%;font-size: 15px;
   height: 35px;margin-right: 3%;" onFocus="this.blur();" />
   <input type="text" class='input float_left' id='weekday' placeholder="星期" readonly style="width:40%;margin-left:3%;font-size: 15px;
   height: 35px;margin-right: 3%;" onFocus="this.blur();" />
 	
 	
 </div>
	
	<div class="list"  style="margin-top: 18%;padding:0 7% 0 7%" >
		<ul class="list-group assess_list">
		</ul>
	</div>
	<script>
		$(function(){
			$.ajax({
				url: $("input[name='url']").val()+'Home/Class_Assess/searchClassChange/1',
				type: 'POST',
				dataType: 'json',
				async:false,
				data: {teacher_id: 0,classroom:0,classname:0},
				success:function(data){
					if(data.status){
						var t=JSON.parse(data.v);
						if(t['list']==null){
							$(".assess_list").html("请选择教学周！");
						}else{
							var show="";
						$.each(t['list'], function(k, v) {
							 // show=show+v['start_time'];
							 if(v['classroom']==null){
							 	var classroom='';
							 }else{
							 	var classroom=v['classroom']+'-';
							 }
							 // show=show+"<li class=list-group-item onclick=doAsses(this) teacher_id="+v['teacher_id']+" class_id="+v['id']+">"+v['teacher_name']+"--"+v['name']+"<div>"+classroom+"-"+v['classname']+"</div></li>";
						});
						}
						$(".teacher_name").append("<option value='0'>选择授课教师</option>");
						$.each(t['teacher_list'], function(k, v) {
						   $(".teacher_name").append("<option value='"+v['id']+"'>"+v['username']+"</option>");
						});
						$(".assess_list").html(show);
					}
				}
			})	
			var max_week=$("#max_week").val();
			var item=new Array();
			for(var i=1;i<=max_week;i++){
				item.push(i);
			}			
			new MobileSelect({
			  trigger: '#select_date',
			  title: '教学周',
			wheels: [
			            {data:item}
			  ],
			  position:[0],//初始化定位 打开时默认选中的哪个 如果不填默认为0
			  callback:function(indexArr, data){
			        $('#select_date').val(data[0]);
			        $('#select_date').blur();
			        $('#search').click();
			  }
			})

			 weekday = new MobileSelect({
		      trigger: '#weekday',
		      title: '请选择星期',
		    wheels: [
		                {data:['周一', '周二', '周三', '周四', '周五']}
		      ],
		      position:[0],//初始化定位 打开时默认选中的哪个 如果不填默认为0
		      callback:function(indexArr, data){
		            $("#weekday").val(data[0]);
		            $("#weekday").blur();
		            $('#search').click();
		      }
		    });
			new MobileSelect({
		      trigger: '#term',
		      title: '请选择学期',
		    wheels: [
		                {data:['第一学期', '第二学期']}
		      ],
		      position:[0],//初始化定位 打开时默认选中的哪个 如果不填默认为0
		      callback:function(indexArr, data){
		            $("#term").val(data[0]);
		            $("#term").blur();
		            $('#search').click();
		      }
		    });


			
			//日期选择
			// new Jdate({
			//   el: '#select_date',
			//   format: 'YYYY-MM-DD',
			//   beginYear: 2000,
			//   endYear: 2100
			// })

			// $('#teacher_name').searchableSelect();
			// 初始化搜索插件
    		$('.teacher_name').anselcfg({});
    		$('.ansel_ok').click(function(){
    			 $("#search").click();
    		})
			//div变化ajax请求				
			$("#search").click(function(event) {
				// $(".searchable-select-holder").bind('DOMNodeInserted', function(e) { 
					var t=new Array();
					// $('.selected').each(function (k,v){
					// 	t[k]=$(this).attr('data-value');
					// });
					var teacher_name=$(".teacher_name").val();
					var date=$("#select_date").val();
					var weekday=$("#weekday").val();
					var term=$("#term").val();
					if(date==''){
						// var dialog1 = jqueryAlert({
		    //                 'icon': $('input[name="url"]').val() + 'public/home/alert/img/error.png',
		    //                 'content': '请选择教学周',
		    //                 'closeTime': 2000,
		    //             })
		    //             return;
					}
					if(weekday==''){
						// var dialog1 = jqueryAlert({
		    //                 'icon': $('input[name="url"]').val() + 'public/home/alert/img/error.png',
		    //                 'content': '请选择星期',
		    //                 'closeTime': 2000,
		    //             })
		    //             return;
					}
					$.ajax({
						url: $("input[name='url']").val()+'Home/Class_Assess/searchClassChange',
						type: 'POST',
						dataType: 'json',
						data: {teacher_name: teacher_name,date:date,weekday:weekday,term:term},
						success:function(data){
							if(data.status){
								var t=JSON.parse(data.v);
								console.log(t);
								var show="";
								if(t['list'].length==0){
									var dialog1 = jqueryAlert({
					                    'icon': $('input[name="url"]').val() + 'public/home/alert/img/error.png',
					                    'content': '没有搜索到数据',
					                    'closeTime': 2000,
					                })
									$('.assess_list').html('<li>没有搜索到数据</li>');
					                return;
								}
								$.each(t['list'], function(k, v) {
									 // show=show+v['start_time'];
									 show=show+"<li class=list-group-item onclick=doAsses(this) teacher_id='"+v['teacher_id']+"' teacher_name='"+v['teacher_name']+"' classroom='"+v['classroom_d']+"' classname='"+v['classname']+"' class_id='"+v['id']+"'>"+v['teacher_name']+"--"+v['name']+"<div>"+v['classroom_d']+"-"+v['classname']+"</div></li>";
								});
								
								$(".assess_list").html(show);
							}
						}
					})	
					
				// });
			});
			})

		function doAsses(t){
			var teacher_id= $(t).attr('teacher_id');
			var teacher_name= $(t).attr('teacher_name');
			var classroom= $(t).attr('classroom');
			// var classname= $(t).attr('class_name');
			var class_id=$(t).attr('class_id');
			window.location.href=$("input[name='url']").val()+"Home/Class_Assess/Index/0/"+teacher_id+"/"+class_id+"/"+classroom;
			
			
		}
		</script>



	</body>
	</html>